<template>
  <div class="farmInfo-container">
    <div class="farmInfo-item">
      <img src="../assets/imgs/icon_01_fczs.png" />
      <div class="addright">
        <div class="area">占地面积</div>
        <span class="unit-pf">{{ area }} 平方米</span>
      </div>
    </div>
    <div class="farmInfo-item">
      <img src="../assets/imgs/icon_01_fqs.png" />
      <div class="addright">
        <div class="area">养殖规模</div>
        <span class="unit-yzz">{{ breedNum }} 只</span>
      </div>
    </div>
    <div class="farmInfo-item">
      <img src="../assets/imgs/icon_01_tfy.png" />
      <div class="addright">
        <div class="area">存栏数量</div>
        <span class="unit-clz">{{ cunLanNum }} 只</span>
      </div>
    </div>
    <div class="farmInfo-item">
      <img src="../assets/imgs/icon_01_ncl.png" />
      <div class="addright">
        <div class="area">从业人员</div>
        <span class="unit-r">{{ peopleNum }} 人</span>
      </div>
    </div>
  </div>

</template>

<script setup>
import { ref } from 'vue';

import { getAllInfo } from '@/apis/allinfo/allinfo'

const area = ref(0)
const breedNum = ref(0)
const cunLanNum = ref(0)
const peopleNum = ref(0)


const fetchAllInfo = async () => {
  const res = await getAllInfo()
  const ary = res.data.data
  console.log(res.data.data)
  // area.value = res.data.data[1].value
  // breedNum.value = res.data.data[1].value.replace("只", " 只")
  // cunLanNum.value = res.data.data[3].value.replace("只", " 只")
  // peopleNum.value = res.data.data[2].value.replace("人", " 人")
  ary.forEach((item, index) => {
    if (item.configSign == "footprint") {
      area.value = item.configValue
    } else if (item.configSign == "breeding-scale") {
      breedNum.value = item.configValue
    } else if (item.configSign == "herd-inventory") {
      cunLanNum.value = item.configValue
    } else if (item.configSign == "workforce ") {
      peopleNum.value = item.configValue
    }
  });
}

fetchAllInfo()




// import { getAllInfo } from '@/apis/allinfo/allinfo.js'

// const fetchAllInfo = async () => {
//   const resp = await getAllInfo()
//   console.log("resp11111111111111111111111111111111111111111111111111111" + resp.data)
//   alert(123)
// }

// fetchAllInfo()
</script>

<style lang="less" scoped>
.farmInfo-container {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 2.8125rem;
  background-image: url(../assets/imgs/icon_ezey_new.png);
  background-repeat: no-repeat;
  background-size: 100%;
  padding: .875rem .25rem .25rem;
  box-sizing: border-box;
  margin-top: .15rem;
  flex-wrap: wrap;

  .farmInfo-item {
    width: 2.25rem;
    height: .6875rem;
    display: flex;
    box-shadow: inset --0.125rem .0125rem .125rem .0125rem #00559a;
    border-radius: .1rem;
    background: #00203d;
    border: .0125rem solid #52ffff;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;

    .addright {
      margin-left: .0625rem;
      width: 1.25rem;
      font-size: .165rem;
      text-align: center;

      .area {
        margin-bottom: .0625rem;
      }

      .unit-pf {
        color: rgba(255, 204, 0, 1);
      }

      .unit-yzz {
        color: rgba(45, 198, 255, 1);
      }

      .unit-clz {
        color: rgba(22, 252, 129, 1);
      }

      .unit-r {
        color: rgba(82, 255, 255, 1);
      }
    }
  }
}
</style>